package org.ranch.api;

import org.ranch.api.service.ConceptService;
import org.ranch.api.utils.RanchUtil;
import org.ranch.model.Concept;

/**
 * This class contains definition of the default system defined concepts
 * 
 */
public final class DefaultConcepts {

    /**
     * default constructor
     */
    private DefaultConcepts() {

    }

    /**
     * Bull concept
     */
    @ConceptAnnotation(ConceptCategories = { DefaultConceptCategories.ANIMAL_TYPE },
	    description = "Bull", id = "C4E7DED6-43C9-46C1-8528-B12DC2B0F07F")
    public static final String BULL = "Bull";

    /**
     * Cow concept
     */
    @ConceptAnnotation(ConceptCategories = { DefaultConceptCategories.ANIMAL_TYPE },
	    description = "Cow", id = "752543F5-AE24-404B-884F-209B4FFB8EE7")
    public static final String COW = "COW";

    /**
     * Goat concept
     */
    @ConceptAnnotation(ConceptCategories = { DefaultConceptCategories.ANIMAL_TYPE },
	    description = "Goat", id = "3AC11558-79E0-4336-9274-630D4848BC4B")
    public static final String GOAT = "Goat";

    /**
     * Sheep concept
     */
    @ConceptAnnotation(ConceptCategories = { DefaultConceptCategories.ANIMAL_TYPE },
	    description = "Sheep", id = "024BF3CB-C5C5-4124-A70D-9D1317E7AA41")
    public static final String SHEEP = "Sheep";
    
    /**
     * default manager responsibility
     */
    @ConceptAnnotation(ConceptCategories = { DefaultConceptCategories.RESPONSIBILITY_TYPE },
	    description = "Manager", id = "b678895c-ac66-11e0-8649-002655bc695f")
    public static final String RESPONSIBILITY_MANAGER = "Manager";
    
    @ConceptAnnotation(ConceptCategories = { DefaultConceptCategories.RESPONSIBILITY_TYPE },
	    description = "Owner", id = "0FA3E02C-B444-4cbf-BDC0-89B0C2970740")
    public static final String RESPONSIBILITY_OWNER = "Owner";
    
    /**
     * default animal color
     */
    @ConceptAnnotation(ConceptCategories = { DefaultConceptCategories.COLOR_TYPE },
	    description = "Black", id = "bWEF2335c-ac66-11e0-8649-0026233DE2")
    public static final String COLOR_BLACK = "Black";
    
    @ConceptAnnotation(ConceptCategories = { DefaultConceptCategories.COLOR_TYPE },
	    description = "White", id = "25224RRTR-B444-4cbf-BDC0-DWEWDKIJUAHX")
    public static final String COLOR_WHITE = "White";
    
    
    /**
     * default health status
     */
    @ConceptAnnotation(ConceptCategories = { DefaultConceptCategories.HEALTH_STATUS_TYPE },
	    description = "Sick", id = "b678895c-ac66-RWEQHPOS-0026876YYf")
    public static final String SICK = "Sick";
    
    @ConceptAnnotation(ConceptCategories = { DefaultConceptCategories.HEALTH_STATUS_TYPE },
	    description = "Dead", id = "QQQWW02C-B444-4cbf-BDC0-89JJYSHH0")
    public static final String DEAD = "Dead";
    
    /**
     * default animal breed
     */
    @ConceptAnnotation(ConceptCategories = { DefaultConceptCategories.BREED_TYPE },
	    description = "Local", id = "F334d95c-ac66-11e0-8649-987762995f")
    public static final String BREED_LOCAL = "Local";
    
    @ConceptAnnotation(ConceptCategories = { DefaultConceptCategories.BREED_TYPE },
	    description = "Hybrid", id = "rewe3wew-B444-4cbf-Jush-EWeewewsS740")
    public static final String BREED_HYBRID = "Hybrid";
    
    /**
     * default animal statu
     */
    @ConceptAnnotation(ConceptCategories = { DefaultConceptCategories.STATUS_TYPE },
	    description = "Calf", id = "F334d95c-0000-11e0-8649-9877FFF5f")
    public static final String STATUS_CALF = "Calf";
    
    @ConceptAnnotation(ConceptCategories = { DefaultConceptCategories.STATUS_TYPE},
	    description = "Sold", id = "U8893wew-B444-4cbf-Jush-EW990TTS740")
    public static final String STATUS_SOLD = "Sold";
    
    

    public static Concept getConcept(ConceptService conceptService, String name) {
	return conceptService.getConceptById(getConceptId(name));
    }

    private static String getConceptId(String name) {
	try {
	    ConceptAnnotation annotation = RanchUtil.getConceptFieldAnnotation(
		    DefaultConcepts.class, name);
	    if (annotation != null) {
		return annotation.id();
	    }

	} catch (SecurityException e) {
	    e.printStackTrace();
	} catch (NoSuchFieldException e) {
	    e.printStackTrace();
	}

	return null;
    }
}
